'use strict';
module.exports = {
	/**
	 * 剧集收费金豆数
	 * @url client/pay/kh/TvSerierPay 前端调用的url参数地址
	 * data 请求参数
	 * @param {String} params1  参数1
	 */
	main: async (event) => {
		let {
			data = {}, userInfo, util, filterResponse, originalParam
		} = event;
		let {
			customUtil,
			uniID,
			config,
			pubFun,
			vk,
			db,
			_
		} = util;
		let {
			uid,
			tv_id,
			serialNo,
			dramaId
		} = data;
		let res = {
			code: 0,
			msg: ""
		};
		
		// 业务逻辑开始-----------------------------------------------------------
		if(tv_id==="undefined"||!tv_id){
			 let info = await vk.baseDao.findByWhereJson({
				dbName: "a_tv",
				whereJson: {
					drama_id: Number(dramaId),
				}
			});
			tv_id=info._id
		}
		let series_info = await vk.baseDao.findByWhereJson({
			dbName: "a_tv_series",
			whereJson: {
				tv_id: tv_id,
				series: serialNo
			}
		});
		console.log("series_info", series_info);
		//如果该集的支付金豆数为0，直接return;避免免费集自动支付的问题
		// if (pay_amount == 0) {
		// 	return res;
		// }
		res.pay_amount = series_info.pay;



		// 业务逻辑结束-----------------------------------------------------------
		return res;
	}
}